tsc hello.ts
指令意思是,用 typescript compiler 去執行TypeScript的編譯器,編譯hello.ts 檔案,會 產生 hello.js檔案
// hello.ts
// 相減函式
function subtract (num1:number, num2: number) {
return num1-num2
}
const total = subtract(5,3)
console.log(total)
// hello.js
// 相減函式
function subtract(num1, num2) {
return num1 - num2;
}
const total = subtract(5, 3);
console.log(total);